package com.huonan.designpattern.piplie.dts;

import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description TODO
 * @Author lxp
 * @Date 2023/2/3 上午11:10
 * @Version V1.0
 **/
public class FilterHandler implements Handler<List<FileEntity>, List<FileEntity>> {

    private int THREAD_SIZE = 2;

    @Override
    public List<FileEntity> process(List<FileEntity> input) {
        ExecutorService threadPool = Executors.newFixedThreadPool(THREAD_SIZE);


        return null;
    }

    private String  filer(String file) {

        //TODO 读取Redis
        List<String> idList = new ArrayList<>();
      //  List<String> lines = FileUtil.readUtf8Lines(file);
        // TODO 解压临时文件
        BufferedReader reader = FileUtil.getReader(file, "UTF-8");
        StringBuilder sb = new StringBuilder();
        String line;
        try {
            if ((line = reader.readLine()) != null) {
                JSONObject jsonObject = JSONUtil.parseObj(line);
                String kwId = jsonObject.getStr("kw_id");
                if (idList.contains(kwId)) {
                    jsonObject.append("bool_preView",false);
                }
                String jsonStr = JSONUtil.toJsonStr(jsonObject);
                sb.append(jsonStr);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        //TODO 压缩
        String zipFIle = null;
        return  zipFIle;
    }
}
